﻿namespace PMS.Client.Controls
{
    using DevComponents.DotNetBar.Controls;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class UCDataGridView : DataGridViewX
    {
        private IContainer components;

        public UCDataGridView()
        {
            this.components = null;
            this.InitializeComponent();
        }

        public UCDataGridView(IContainer container)
        {
            this.components = null;
            container.Add(this);
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            ((ISupportInitialize) this).BeginInit();
            base.SuspendLayout();
            style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style.BackColor = SystemColors.Window;
            style.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            style.ForeColor = SystemColors.ControlText;
            style.SelectionBackColor = SystemColors.Highlight;
            style.SelectionForeColor = SystemColors.ControlText;
            style.WrapMode = DataGridViewTriState.False;
            base.DefaultCellStyle = style;
            base.GridColor = Color.FromArgb(0xd0, 0xd7, 0xe5);
            base.HighlightSelectedColumnHeaders = false;
            base.RowTemplate.Height = 0x17;
            base.RowsAdded += new DataGridViewRowsAddedEventHandler(this.UCDataGridView_RowsAdded);
            ((ISupportInitialize) this).EndInit();
            base.ResumeLayout(false);
        }

        private void UCDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            base.RowHeadersWidth = 50;
            for (int i = 0; i < base.Rows.Count; i++)
            {
                base.Rows[i].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                base.Rows[i].HeaderCell.Value = (i + 1).ToString();
            }
        }
    }
}

